package com.sufen.seckill.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author sufen
 * @Date 2021/10/25 16:00
 * @Version 1.0
 * 功能描述：消息的发送者
 * MQ
 */
@Service
@Slf4j
public class MQSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;


//    发送秒杀信息

    public void sendSeckillMessage(String message){
        log.info("发送消息："+message);
        rabbitTemplate.convertAndSend("seckillExchange","seckill.message",message);
    }

//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    public void send(Object msg){
//        log.info("发送消息："+msg);
//        rabbitTemplate.convertAndSend("fanoutExchange","",msg);
//    }
//
//    public void send01(Object msg){
//        log.info("发送red消息："+msg);
//        rabbitTemplate.convertAndSend("directExchange","queue.red",msg);
//    }
//
//    public void send02(Object msg){
//        log.info("发送green消息："+msg);
//        rabbitTemplate.convertAndSend("directExchange","queue.green",msg);
//    }
//
//    public void send03(Object msg){
//        log.info("发送topic消息,queue_topic01接收"+msg);
//        rabbitTemplate.convertAndSend("topicExchange","queue.abc",msg);
//    }
//    public void send04(Object msg){
//        log.info("发送topic消息,两个queue_topic01和02都接收"+msg);
//        rabbitTemplate.convertAndSend("topicExchange","xyz.queue.abc",msg);
//    }
}
